import React, { useState, useContext } from 'react'
import { Modal, Input, Form, Upload } from 'antd'
import utils from '@utils'

export default props => {
  let [form] = Form.useForm()
  let { params } = props

  const onFinish = () => {
    form.validateFields()
      .then(res => {
        let data = {
          ...params,
          ...res
        }
        utils.post('/api/order/bindSharer', data).then(res => {
          if (res.errorCode == 0) {
            props.onOk()
          }
        })
      })
      .catch(err => { })
  }

  return <Modal
    title={'增加分享人'}
    visible={true}
    onOk={onFinish}
    onCancel={() => {
      props.onCancel()
    }}
    okText="确认"
    cancelText="取消"
  >
    <Form form={form} initialValues={params}>
      <Form.Item name="phone" label="分享人手机号"
        rules={
          [{
            required: true,
            message: '请输入分享人手机号',
          }]
        }
      >
        <Input rows={4} placeholder='请输入分享人手机号' />
      </Form.Item>
    </Form>
  </Modal>
}